package org.study.neo4j.boot.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.study.neo4j.boot.dto.ActorDTO;
import org.study.neo4j.boot.model.Movie;
import org.study.neo4j.boot.service.MovieService;

import java.util.Collection;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年04月14日
 */
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RestController
@RequestMapping("/api/movie")
public class MovieController {
    private final MovieService movieService;

    @GetMapping("/deleteMovie")
    public Object deleteAllMovie() {
        movieService.deleteAllMovie();
        return "删除movie数据成功";
    }

    @GetMapping("/deleteActor")
    public Object deleteAllActor() {
        movieService.deleteAllActor();
        return "删除person数据成功";
    }

    @GetMapping("/delete")
    public Object deleteAllData() {
        movieService.deleteAllData();
        return "清空(删除所有)数据成功";
    }

    @GetMapping("/add")
    public Object addData() {
        movieService.addData();
        return "添加模拟数据成功";
    }

    @GetMapping("/repository")
    public Movie findMovieByRepository() {
        return movieService.findMovieByRepository();
    }

    @GetMapping("/allActor")
    public Collection<ActorDTO> getAllActor() {
        return movieService.getAllActor();
    }

    @GetMapping("/template")
    public Movie findMovieByTemplate() {
        return movieService.findMovieByTemplate();
    }

    @GetMapping("/count")
    public Long count() {
        return movieService.count();
    }
}
